package cn.fl.system.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSONObject;

import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.system.condition.SysFlCompInfoQueryCondition;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysFlCompInfoService;
import cn.fl.system.vo.SysFlCompInfoVO;
import net.sf.json.JSONArray;

/**
 * @Description: 融资租赁公司信息表 控制层
 */
@Controller
@RequestMapping("/system/sysFlCompInfo")
public class SysFlCompInfoController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(SysFlCompInfoController.class);

	/**
	 * SysFlCompInfo 服务层BEAN
	 */
	@Autowired
	private ISysFlCompInfoService sysFlCompInfoService;

	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toListPage.do", method = { RequestMethod.GET})
	public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
		BaseLogUtils.info(logger, "toListPage", "加载融资租赁公司列表页面.",CurrentThreadContext.getCurrentUserName());
		ModelAndView view = new ModelAndView("system/sysFlCompInfo/sysSysFlCompInfoList");
		return view;
	}

	/**
	 * 到修改页面
	 */
	@RequestMapping(value = "/toModifyPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		logger.info("加载SysFlCompInfo Modify页面.");
		BaseLogUtils.info(logger, "toModifyPage", "加载融资租赁公司修改页面.",CurrentThreadContext.getCurrentUserName());
		ModelAndView view = new ModelAndView("system/sysFlCompInfo/sysSysFlCompInfoModify");
		
		view.addObject("id", id);
		//公司级别
		List<KeyValueVO> searchCompLvlCdList = this.sysFlCompInfoService.searchCompLvlCdList();
		if(searchCompLvlCdList!=null){
			KeyValueVO dfCompLvlCd = searchCompLvlCdList.get(0);
			view.addObject("dfCompLvlCd", dfCompLvlCd);
		}
		// 公司隶属
		List<KeyValueVO> searchCompPropCdList = this.sysFlCompInfoService.searchCompPropCdList();
		if(searchCompPropCdList!=null){
			view.addObject("searchCompPropCdList", searchCompPropCdList);
		}
		// 公司性质
		List<KeyValueVO> searchCompTypCdList = this.sysFlCompInfoService.searchCompTypCdList();
		if(searchCompTypCdList!=null){
			view.addObject("searchCompTypCdList", searchCompTypCdList);
		}
		// 公司规模--员工数量
		List<KeyValueVO> searchEmpQtyCdList = this.sysFlCompInfoService.searchEmpQtyCdList();
		if(searchEmpQtyCdList!=null){
			view.addObject("searchEmpQtyCdList", searchEmpQtyCdList);
		}
		return view;
	}
	
	/**
	 * 到新增页面
	 */
	@RequestMapping(value = "toAdd.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toModifyFlCompPage(HttpServletRequest request, HttpServletResponse response) {
		
		BaseLogUtils.info(logger, "toModifyFlCompPage", "加载融资租赁公司新增页面.",CurrentThreadContext.getCurrentUserName());
		ModelAndView view = new ModelAndView("system/sysFlCompInfo/sysSysFlCompInfoAdd");
		
		//公司级别
		List<KeyValueVO> searchCompLvlCdList = this.sysFlCompInfoService.searchCompLvlCdList();
		if(CollectionUtils.isNotEmpty(searchCompLvlCdList)){
			KeyValueVO dfCompLvlCd = searchCompLvlCdList.get(0);
			view.addObject("dfCompLvlCd", dfCompLvlCd);
		}
		//公司隶属
		List<KeyValueVO> searchCompPropCdList = this.sysFlCompInfoService.searchCompPropCdList();
		if(searchCompPropCdList!=null){
			view.addObject("searchCompPropCdList", searchCompPropCdList);
		}
		//公司性质
		List<KeyValueVO> searchCompTypCdList = this.sysFlCompInfoService.searchCompTypCdList();
		if(searchCompTypCdList!=null){
			view.addObject("searchCompTypCdList", searchCompTypCdList);
		}
		//公司规模--员工数量
		List<KeyValueVO> searchEmpQtyCdList = this.sysFlCompInfoService.searchEmpQtyCdList();
		if(searchEmpQtyCdList!=null){
			view.addObject("searchEmpQtyCdList", searchEmpQtyCdList);
		}
		return view;
	}

	/**
	 * 初始化列表狮桥公司基础信息
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		//查询条件
		String fulNm = request.getParameter("fulNm");
		String sortName = request.getParameter("sortname");
		String sortOrder = request.getParameter("sortorder");
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		SysFlCompInfoQueryCondition qc = new SysFlCompInfoQueryCondition();
		//设置查询条件中的系统代码以及组织架构
		qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		if (StringUtils.isNotEmpty(fulNm)) {
			qc.setFulNm(fulNm);
		}
		
		//sortName 到服务端会转换成为数据库字段
		if(StringUtils.isNotEmpty(sortName) && StringUtils.isNotEmpty(sortOrder)){
				qc.setSortName(sortName);
				qc.setSortOrder(sortOrder);
		}
		page.setCondition(qc);

		BaseLogUtils.info(logger, "initList", "初始化融资租赁公司列表页面数据.DATA:"+JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
		//TODO SOMETHING
		Pager pager = this.sysFlCompInfoService.searchListPage(page);
		List<SysFlCompInfoVO> list = (List<SysFlCompInfoVO>) pager.getResultList();
		ListPageVO<SysFlCompInfoVO> listPage = new ListPageVO<SysFlCompInfoVO>(list, pager.getTotalCount());
		return listPage;
	}

	/**
	 * 删除狮桥公司基础信息
	 */
	@RequestMapping(value = "/removeByIds.do", method = {RequestMethod.POST })
	@ResponseBody
	public DataResultVO removeById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String ids = request.getParameter("ids");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		if(StringUtils.isEmpty(ids)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "removeById", "删除融资租赁公司数据,主键参数为空！", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		List<Long> idsList = new ArrayList<Long>();
		JSONArray idsArray = JSONArray.fromObject(ids);
		for (Object object : idsArray) {
			idsList.add(Long.valueOf(object.toString()));
		}
		try {
			boolean success = this.sysFlCompInfoService.removeSysFlCompInfoByIds(idsList);
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_DELETE_FAIL);
				BaseLogUtils.info(logger, "removeById", "删除融资租赁公司数据失败,ID:"+idsList.toString(), CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "removeById", "删除融资租赁公司数据成功,ID:"+idsList.toString(), CurrentThreadContext.getCurrentUserName());
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "removeById", "删除融资租赁公司数据失败,ID:"+idsList.toString()+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "removeById", "删除融资租赁公司数据失败,系统错误.ID:"+idsList.toString()+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}
	/**
	 * 显示详情页面
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/toDetailPage.do", method = { RequestMethod.GET})
	@ResponseBody
	public ModelAndView toDetailPage(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String scpId = request.getParameter("scpId");
		BaseLogUtils.info(logger, "toDetailPage", "加载融资租赁公司详情页面",CurrentThreadContext.getCurrentUserName());
		ModelAndView view = new ModelAndView("system/sysFlCompInfo/sysSysFlCompInfoInfo");
		view.addObject("scpId", scpId);
		return view;
	}
	

	
	/**
	 * 得到一条记录
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getById.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "getById", "获取融资租赁公司数据,主键参数为空！", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			SysFlCompInfoVO vo = this.sysFlCompInfoService.selectById(Long.valueOf(id));
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getById", "获取融资租赁公司数据不存在,ID:"+id, CurrentThreadContext.getCurrentUserName());
			}
			result.setData(vo);
			BaseLogUtils.info(logger, "getById", "获取融资租赁公司数据成功,ID:"+id, CurrentThreadContext.getCurrentUserName());
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getById", "获取融资租赁公司数据失败,ID:"+id+".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getById", "获取融资租赁公司数据失败,系统错误.ID:"+id+".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}

	/**
	 * 新增狮桥公司基础信息
	 */
	@RequestMapping(value = "/add.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		SysFlCompInfoVO entity = new SysFlCompInfoVO();
		try {
			entity = this.getRequestParamForSysFlCompAdd(request);
			
			Long id = this.sysFlCompInfoService.add(entity);
			result.setData(id);
			BaseLogUtils.info(logger, "add", "新增融资租赁公司数据成功,ID:"+id+".DATA:"+JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "add", "新增融资租赁公司数据失败.DATA:"+JSONObject.toJSONString(entity)+".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "add", "新增融资租赁公司数据失败,系统错误.DATA:"+JSONObject.toJSONString(entity)+".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}

	/**
	 * 修改狮桥公司基础信息
	 */
	@RequestMapping(value = "/modify.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,SysLogConstant.LOG_CMM_UPDATE_SUCC);
		SysFlCompInfoVO entity = new SysFlCompInfoVO();
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modify", "修改融资租赁公司信息,主键参数为空！.ID:"+id, CurrentThreadContext.getCurrentUserName());
			return result;
		}
		try {
			entity = this.getRequestParamForSysFlCompModify(request);
			entity.setId(Long.valueOf(id));
			boolean success = this.sysFlCompInfoService.modifySysFlCompInfo(entity);
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_UPDATE_FAIL);
				BaseLogUtils.info(logger, "modify", "修改融资租赁公司数据失败.DATA:"+JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "modify", "修改融资租赁公司数据成功.DATA:"+JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modify", "修改融资租赁公司数据失败.DATA:"+JSONObject.toJSONString(entity)+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modify", "修改融资租赁公司数据失败,系统错误.DATA:"+JSONObject.toJSONString(entity)+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	/**
	 * 启用狮桥公司基础信息
	 */
	@RequestMapping(value = "/enable.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object enable(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,SysLogConstant.LOG_CMM_ENABLE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "enable", "启用融资租赁公司失败,主键参数为空.", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		SysFlCompInfoVO sysFlCompInfoVO = new SysFlCompInfoVO();
		sysFlCompInfoVO.setId(Long.valueOf(id));
		//启用
		sysFlCompInfoVO.setIsValid(BaseConstant.IS_YESNO_YES);
		try {
			
			boolean success = this.sysFlCompInfoService.modifyEnAbleSysFlCompInfo(sysFlCompInfoVO);
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_ENABLE_FAIL);
				BaseLogUtils.info(logger, "enable", "启用融资租赁公司失败,ID:"+id, CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "enable", "启用融资租赁公司成功,ID:"+id, CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "enable", "启用融资租赁公司失败,ID:"+id+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "enable", "启用融资租赁公司失败,系统错误.ID:"+id+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	/**
	 * 禁用狮桥公司基础信息
	 */
	@RequestMapping(value = "/disable.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object disable(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,SysLogConstant.LOG_CMM_DISABLE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "disable", "禁用融资租赁公司主键参数不存在.", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		SysFlCompInfoVO sysFlCompInfoVO = new SysFlCompInfoVO();
		sysFlCompInfoVO.setId(Long.valueOf(id));
		//禁用
		sysFlCompInfoVO.setIsValid(BaseConstant.IS_YESNO_NO);
		try {
			
			boolean success = this.sysFlCompInfoService.modifyDisAbleSysFlCompInfo(sysFlCompInfoVO);
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_DISABLE_FAIL);
				BaseLogUtils.info(logger, "disable", "禁用融资租赁公司失败,ID:"+id, CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "disable", "禁用融资租赁公司成功,ID:"+id, CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "disable", "禁用融资租赁公司失败,ID:"+id+".ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "disable", "禁用融资租赁公司失败,系统错误.ID:"+id+".ERROR"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	
	
	//********************私有方法********************//
	
	/**
	 * 获取狮桥公司请求公共参数(新增修改共用)
	 * @param request 请求
	 * @return 狮桥公司基本信息
	 */
	private SysFlCompInfoVO getRequestParamForSysFlComp(HttpServletRequest request)throws BaseException{
		String compLvlCd = request.getParameter("compLvlCd");//公司级别
		String fulNm = request.getParameter("fulNm");//公司全称
		String shtNm = request.getParameter("shtNm");//公司简称
		String engNm = request.getParameter("engNm");//公司英文名称
		String compPropCd = request.getParameter("compPropCd");//公司隶属
		String compTypCd = request.getParameter("compTypCd");//公司性质
		String empQtyCd = request.getParameter("empQtyCd");//员工数量(公司规模)
		String regDtStr = request.getParameter("regDt");//成立时间
		String expDtStr = request.getParameter("expDt");//营业期限
		String bizLicNo = request.getParameter("bizLicNo");//营业执照注册号
		String taxRegNo = request.getParameter("taxRegNo");//税务登记号
		String orgCode = request.getParameter("orgCode");//组织机构代码证
		String bizScope = request.getParameter("bizScope");//经营范围
		String regCapAmt = request.getParameter("regCapAmt");//注册资本（万元）
		String compTel = request.getParameter("compTel");//公司电话
		String compTax = request.getParameter("compTax");//公司传真
		String regAddr = request.getParameter("regAddr");//公司注册地址
		String officeAddr = request.getParameter("officeAddr");//公司办公地址
		String compRem = request.getParameter("compRem");//COMP_REM
		String repNm = request.getParameter("repNm");//法人姓名
		String repIdNum = request.getParameter("repIdNum");//法人身份证号
		String repOfficTel = request.getParameter("repOfficTel");//法人办公电话
		String repAddr = request.getParameter("repAddr");//法人常住地址
		String repMp = request.getParameter("repMp");//法人手机号
		String lmNm = request.getParameter("lmNm");//联系人姓名
		String lmIdNum = request.getParameter("lmIdNum");//LM_ID_NUM
		String lmAddr = request.getParameter("lmAddr");//联系人常住地址
		String lmMp = request.getParameter("lmMp");//联系人手机号
		
		
		//验证 必填项 以及长度
		if(StringUtils.isBlank(fulNm) || fulNm.length() > 50){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "全称不能为空,并且长度不能大于50个字符。");
		}
		
		if(StringUtils.isBlank(shtNm) || shtNm.length() > 50){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "简称不能为空,并且长度不能大于50个字符。");
		}
		if(StringUtils.isNotBlank(repNm)&& !StringUtils.isCustomerName(repNm)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "法人名字格式不正确");
		}
		if(StringUtils.isNotBlank(lmNm)&& !StringUtils.isCustomerName(lmNm)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "联系人名字格式不正确");
		}
		if(StringUtils.isNotBlank(repIdNum)&& !StringUtils.isIdCardNumber(repIdNum)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "身份证号格式不正确");
		}
		
		if(StringUtils.isNotBlank(regCapAmt) &&!StringUtils.isUnsignedNumeric(regCapAmt)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "注册资金只能为数字");
		}
		if(StringUtils.isNotBlank(compTel) &&!StringUtils.checkMobileNumber(compTel)&&!StringUtils.isFixedPhone(compTel)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "注册电话格式不正确，XXXX-XXXXX或者11位手机号码");
		}
		if(StringUtils.isNotBlank(repOfficTel) &&!StringUtils.checkMobileNumber(repOfficTel)&&!StringUtils.isFixedPhone(repOfficTel)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "法人办公电话格式不正确，XXXX-XXXXX或者11位手机号码");
		}
		if(StringUtils.isNotBlank(repMp) &&!StringUtils.checkMobileNumber(repMp)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请输入11位法人手机号码");
		}
		if(StringUtils.isNotBlank(lmMp) &&!StringUtils.checkMobileNumber(lmMp)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "输入11位联系人手机号码");
		}
		
		SysFlCompInfoVO entity = new SysFlCompInfoVO();
		entity.setCompLvlCd(compLvlCd);
		entity.setFulNm(fulNm);
		entity.setShtNm(shtNm);
		entity.setEngNm(engNm);
		entity.setCompPropCd(compPropCd);
		entity.setCompTypCd(compTypCd);
		entity.setEmpQtyCd(empQtyCd);
		//成立时间 String类型 转换成 Date类型
		if(StringUtils.isNotBlank(regDtStr)){
			
			Date regDt = DateUtils.formatStringToDate(regDtStr, DateUtils.YYYY_MM_DD);
			entity.setRegDt(regDt);
		}
		//营业期限String类型转换成Date类型
		if(StringUtils.isNotBlank(expDtStr)){
			
			Date expDt = DateUtils.formatStringToDate(expDtStr, DateUtils.YYYY_MM_DD);
			entity.setExpDt(expDt);
		}
		entity.setBizLicNo(bizLicNo);
		entity.setTaxRegNo(taxRegNo);
		entity.setOrgCode(orgCode);
		entity.setBizScope(bizScope);
		//注册资本
		if(StringUtils.isNotBlank(regCapAmt)){
		entity.setRegCapAmt(Double.parseDouble(regCapAmt));
		}
		entity.setCompTel(compTel);
		entity.setCompTax(compTax);
		entity.setBizScope(bizScope);
		entity.setRepOfficTel(repOfficTel);
		entity.setRegAddr(regAddr);
		entity.setOfficeAddr(officeAddr);
		entity.setCompRem(compRem);
		entity.setRepNm(repNm);
		entity.setRepIdNum(repIdNum);
		entity.setRepAddr(repAddr);
		entity.setRepMp(repMp);
		entity.setLmNm(lmNm);
		entity.setLmIdNum(lmIdNum);
		entity.setLmMp(lmMp);
		entity.setLmAddr(lmAddr);
		entity.setIsDel(BaseConstant.IS_YESNO_NO);
		return entity;
	}

	/**
	 * 获取狮桥公司请求参数(新增)
	 * @param request 请求
	 * @return 狮桥公司基本信息
	 */
	private SysFlCompInfoVO getRequestParamForSysFlCompAdd(HttpServletRequest request)throws BaseException{
		SysFlCompInfoVO sysFlCompInfoVO = this.getRequestParamForSysFlComp(request);
		sysFlCompInfoVO.setCrtTm(new Date());
		sysFlCompInfoVO.setIsValid(BaseConstant.IS_YESNO_YES);
		sysFlCompInfoVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
		return sysFlCompInfoVO;
		
	}
	
	/**
	 * 获取狮桥公司请求参数(修改)
	 * @param request 请求
	 * @return 狮桥公司基本信息
	 */
	private SysFlCompInfoVO getRequestParamForSysFlCompModify(HttpServletRequest request)throws BaseException{
		SysFlCompInfoVO sysFlCompInfoVO = this.getRequestParamForSysFlComp(request);
		sysFlCompInfoVO.setMdfTm(new Date());
		sysFlCompInfoVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
		return sysFlCompInfoVO;
		
	} 
}

